package com.hnkywl.jip.action;

import com.hnkywl.jip.service.BasicService;
import net.ruixin.web.struts2.SimpleActionSupport;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * 说明：
 * 包:        com.hnkywl.jip.dao
 * 类描述:    [一句话描述该类的功能]
 * 创建人:    ZHUCHG
 * 创建时间: 13-3-4 上午8:56
 * 修改人:    ZHUCHG
 * 修改时间: 13-3-4 上午8:56
 * 修改备注: [说明本次修改内容]
 * 版本:        [v1.0]
 */
@Namespace("/basic")
public class BasicAction extends SimpleActionSupport {
    private String key;
    private Integer id;
    private Integer companyId;
    private Integer deptId;
    private List<Object[]> voucherTypeList;
    private List<Object[]> customerList;
    private List<Object[]> subjectList;
    private List<Object[]> deptList;
    private List<Object[]> userList;

    private BasicService basicService;

    @Action("find_customer_json")
    public String findCustomerJson() {
        customerList = basicService.findCustomer(key);
        return SUCCESS;
    }

    @Action("find_voucher_type_json")
    public String getVoucherTypeCode() {
        voucherTypeList = basicService.getVoucherTypeCode(id);
        return SUCCESS;
    }

    @Action("subject_tree_json")
    public String getAllSubject() {
        if (companyId != null)
            subjectList = basicService.getAllSubject(companyId);
        return SUCCESS;
    }

    @Action("find_dept_json")
    public String findDeptJson() {
        if (companyId != null)
            deptList = basicService.findDept(companyId);
        return SUCCESS;
    }

    @Action("find_user_json")
    public String findUserJson() {
        if (deptId != null)
            userList = basicService.findUser(deptId);
        return SUCCESS;
    }

    //=============getter=================
    public List<Object[]> getCustomerList() {
        return customerList;
    }

    public List<Object[]> getVoucherTypeList() {
        return voucherTypeList;
    }

    public List<Object[]> getSubjectList() {
        return subjectList;
    }

    public List<Object[]> getDeptList() {
        return deptList;
    }

    public List<Object[]> getUserList() {
        return userList;
    }

    //==============setter======================
    public void setKey(String key) {
        this.key = key;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public void setCompanyId(Integer companyId) {
        this.companyId = companyId;
    }

    public void setDeptId(Integer deptId) {
        this.deptId = deptId;
    }

    @Autowired
    public void setBasicService(BasicService basicService) {
        this.basicService = basicService;
    }
}
